package com.hongkuncheng.cms.model;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;
import java.io.Serializable;

@Entity
public class Dataitem implements Serializable {
    protected int id;
    protected String name;
    protected String dataname;
    protected int datacount;
    protected boolean dynamiccolumns;
    protected int dateastrict;
    protected boolean haveimage;
    protected boolean pagesign;
    protected Datamodel datamodel;
    protected Datasortfield datasortfield1;
    protected Datasortmethod datasortmethod1;
    protected Datasortfield datasortfield2;
    protected Datasortmethod datasortmethod2;
    protected Datasortfield datasortfield3;
    protected Datasortmethod datasortmethod3;
    private List<DataitemReColumns> dataitemReColumnses;
    protected List<DataitemReDepartment> dataitemReDepartments;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name", nullable = false, length = 255)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "dataname", nullable = false, length = 255)
    public String getDataname() {
        return dataname;
    }

    public void setDataname(String dataname) {
        this.dataname = dataname;
    }

    @Basic
    @Column(name = "datacount", nullable = false)
    public int getDatacount() {
        return datacount;
    }

    public void setDatacount(int datacount) {
        this.datacount = datacount;
    }

    @Basic
    @Column(name = "dynamiccolumns", nullable = false)
    public boolean isDynamiccolumns() {
        return dynamiccolumns;
    }

    public void setDynamiccolumns(boolean dynamiccolumns) {
        this.dynamiccolumns = dynamiccolumns;
    }

    @Basic
    @Column(name = "dateastrict", nullable = false)
    public int getDateastrict() {
        return dateastrict;
    }

    public void setDateastrict(int dateastrict) {
        this.dateastrict = dateastrict;
    }

    @Basic
    @Column(name = "haveimage", nullable = false)
    public boolean isHaveimage() {
        return haveimage;
    }

    public void setHaveimage(boolean haveimage) {
        this.haveimage = haveimage;
    }

    @Basic
    @Column(name = "pagesign", nullable = false)
    public boolean isPagesign() {
        return pagesign;
    }

    public void setPagesign(boolean pagesign) {
        this.pagesign = pagesign;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Dataitem dataitem = (Dataitem) o;
        return id == dataitem.id &&
                datacount == dataitem.datacount &&
                dynamiccolumns == dataitem.dynamiccolumns &&
                dateastrict == dataitem.dateastrict &&
                haveimage == dataitem.haveimage &&
                pagesign == dataitem.pagesign &&
                Objects.equals(name, dataitem.name) &&
                Objects.equals(dataname, dataitem.dataname);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, dataname, datacount, dynamiccolumns, dateastrict, haveimage, pagesign);
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "model_id", referencedColumnName = "id", nullable = false)
    public Datamodel getDatamodel() {
        return datamodel;
    }

    public void setDatamodel(Datamodel datamodel) {
        this.datamodel = datamodel;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "sortfield1_id", referencedColumnName = "id", nullable = false)
    public Datasortfield getDatasortfield1() {
        return datasortfield1;
    }

    public void setDatasortfield1(Datasortfield datasortfield1) {
        this.datasortfield1 = datasortfield1;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "sortmethod1_id", referencedColumnName = "id", nullable = false)
    public Datasortmethod getDatasortmethod1() {
        return datasortmethod1;
    }

    public void setDatasortmethod1(Datasortmethod datasortmethod1) {
        this.datasortmethod1 = datasortmethod1;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "sortfield2_id", referencedColumnName = "id", nullable = false)
    public Datasortfield getDatasortfield2() {
        return datasortfield2;
    }

    public void setDatasortfield2(Datasortfield datasortfield2) {
        this.datasortfield2 = datasortfield2;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "sortmethod2_id", referencedColumnName = "id", nullable = false)
    public Datasortmethod getDatasortmethod2() {
        return datasortmethod2;
    }

    public void setDatasortmethod2(Datasortmethod datasortmethod2) {
        this.datasortmethod2 = datasortmethod2;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "sortfield3_id", referencedColumnName = "id", nullable = false)
    public Datasortfield getDatasortfield3() {
        return datasortfield3;
    }

    public void setDatasortfield3(Datasortfield datasortfield3) {
        this.datasortfield3 = datasortfield3;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "sortmethod3_id", referencedColumnName = "id", nullable = false)
    public Datasortmethod getDatasortmethod3() {
        return datasortmethod3;
    }

    public void setDatasortmethod3(Datasortmethod datasortmethod3) {
        this.datasortmethod3 = datasortmethod3;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "dataitem")
    public List<DataitemReColumns> getDataitemReColumnses() {
        return dataitemReColumnses;
    }

    public void setDataitemReColumnses(List<DataitemReColumns> dataitemReColumnses) {
        this.dataitemReColumnses = dataitemReColumnses;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "dataitem")
    public List<DataitemReDepartment> getDataitemReDepartments() {
        return dataitemReDepartments;
    }

    public void setDataitemReDepartments(List<DataitemReDepartment> dataitemReDepartments) {
        this.dataitemReDepartments = dataitemReDepartments;
    }
}
